package com.example.springbook.service;

import com.example.springbook.bean.Admin;
import com.example.springbook.dao.AdminDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AdminServiceImpl implements AdminService {
    @Autowired
    private AdminDao adminDao;

    @Override
    public boolean addAdmin(Admin admin) {
        boolean flag=false;
        try{
            adminDao.addAdmin(admin);
            flag=true;
        }catch(Exception e){
            e.printStackTrace();
        }
        return flag;
    }

    @Override
    public boolean updateAdmin(Admin admin) {
        boolean flag=false;
        try{
            adminDao.updateAdmin(admin);
            flag=true;
        }catch(Exception e){
            e.printStackTrace();
        }
        return flag;
    }

    @Override
    public boolean deleteAdmin(int id) {
        boolean flag=false;
        try{
            adminDao.deleteAdmin(id);
            flag=true;
        }catch(Exception e){
            e.printStackTrace();
        }
        return flag;
    }

    @Override
    public String findAdminName(int id) {
        return adminDao.findAdminName(id);
    }

    @Override
    public String selectAdmin(int id){ return adminDao.selectAdmin(id);}

    @Override
    public List<Admin> findAll() {
        return adminDao.findAll();
    }
}
